package com.letcoding.spiderAutoHome.config;

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName HttpClientManagerCfg
 * @Description TODO
 * @Author will
 * @Date 2021/5/6 15:03
 * @Company 北京华焱坤泰科技有限公司
 */
@Configuration
public class HttpClientManagerCfg {

    @Bean
    public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
        // 创建连接管理器
        PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
        // 设置最大连接数
        httpClientConnectionManager.setMaxTotal(50);
        // 设置每个并发连接数
        httpClientConnectionManager.setDefaultMaxPerRoute(20);
        return httpClientConnectionManager;
    }
}
